$(document).ready(function () {

    var viwer;
    var angle = 0;
    var tux;
    var tuy;
    var fw;
    var scale;
    var bol = true,
        resetTimeout;
    var scaleElement;
    var ans;
    var scalea = '';
    var scaleb = '';
    var zIndex = 10;
    var datatype = $("#wrapper").attr("datatype");
    if (datatype == "view") {
        viwer = "../上传/";

    } else {
        viwer = '';
    }


    //loading
    var firstLoadFiles = {
        "files": [
            {
                "type": "IMAGE",
                "source": viwer + "images/game/bg1.jpg",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/bg2.jpg",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/bg3.jpg",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/bg4.jpg",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/bg5.jpg",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/bg6.jpg",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/bg7.jpg",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/car.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/car2.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/houzi.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/moon.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/niao.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/pangxie.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/pangxie.gif",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/qingwa.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/qingwa2.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/shitou.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/shu.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/shu.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/sun_01.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/sun_02.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/sun_03.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/xiezi.gif",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/xiezi2.gif",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/yu.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/yu2.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/yuwang.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/game/yuwang2.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p2/bg.jpg",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p2/p2btn.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p2/p2main.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p3/p3bg1.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p3/p3bg2.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p3/p3bg3.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p4/p4bg.jpg",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p4/p4btn.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p4/p4title.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p6/p6bg.jpg",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p6/p6btn.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p6/p6guang.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p6/p6hui.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p6/p6main.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p6/p6title.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p7/p7che.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p7/p7hou.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p7/p7niao.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p7/p7shi.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p7/p7shu.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p7/p7wang.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p7/p7xie.png",
                "size": 1
            },
            {
                "type": "IMAGE",
                "source": viwer + "images/p7/p7yu.png",
                "size": 1
            },
        ]
    };

    //
    $.html5Loader({
        filesToLoad: firstLoadFiles,
        onBeforeLoad: function () {
        },
        onComplete: function () {
            setTimeout(function(){
                step1();
            },1000)
            // $.html5Loader({filesToLoad: bgLoadFiles});
            // step5();
        },
        onElementLoaded: function (obj, elm) {},
        onUpdate: function (percentage) {
            console.log(percentage);
            $(".p1loadL").css('left',(percentage-100)+'%');

          
            
            // $("body").html(percentage + '%');
        }
    });
    // document.body.addEventListener('touchmove',function(e){e.preventDefault();})
    document.body.addEventListener('touchmove', function (e) {
        e.preventDefault(); //阻止默认的处理方式(阻止下拉滑动的效果)
    }, {
        passive: false
    });

    // $('body').on('touchmove', function (e) {e.preventDefault();});



    // p3动画
    var p3Manhua = new TimelineMax();
    p3Manhua.from($(".p3bg1"), 0.5, {right:'-100%',ease: Power0.easeNone});
    p3Manhua.from($(".p3bg2"), 0.5, {left:'-100%',ease: Power0.easeNone});
    p3Manhua.from($(".p3bg3"), 0.5, {right:'-100%',ease: Power0.easeNone});
    p3Manhua.pause();


    var p3title = new TimelineMax();
    p3title.to($('.p3title'), 1, { display:'block',ease: Power0.easeNone,onStart:function(){p3titles();}},'+=0.5');
    p3title.pause();

    function p3titles (){
        var p3titles =new TimelineMax({repeat:-1});
        p3titles.to($('.p3title'), 1, { rotation: "5deg", transformOrigin: "50% 50%",ease: Power0.easeNone});
        p3titles.to($('.p3title'), 1, { rotation: "-5deg", transformOrigin: "50% 50%",ease: Power0.easeNone});
    } 

    var p3xing = new TimelineMax();
    p3xing.to($('.p3xing'), 1, { display:'block',ease: Power0.easeNone },'+=2');
    p3xing.pause();


    
    


    // p4动画
    var p4Btn = new TimelineMax({});
    p4Btn.to($('.p4btn'), 1, { top: "133.3%",ease: Power0.easeNone});
    p4Btn.from($('.p4btn'), 0.5, { rotationX: "-80deg", transformOrigin: "50% 100%",ease: Power0.easeNone});
    p4Btn.pause();

    // 背景动画
    var ww = $(window).width();
    var wh = $(window).height();
    // alert(ww+','+wh)

    var h = 6*(2000) * ww /750 - 7 + (940) * ww /750;

    var hideHeight =  -h;


    var pw = ww*$("#pangxie").css("width").replace("%", "") / 100;

    $("#pangxie").css("bottom", 27 * pw / 124.2);


    bottom = hideHeight ;


    var bg = new TimelineMax({});

    bg.to($(".box"), 30, {bottom:bottom,ease: Power0.easeNone,onStart:function(){bgChangeSun();}},'+=1');
    
  
    
    bg.pause();
    // 改变太阳位置
    function bgChangeSun(){
        
        setInterval(function(){
            
            if(bg.time() >= 0 && bg.time() < 10){
                // console.log('刚出太阳')
                $('.sun1,.sun2').show();
                $('.sun3,.moon').hide();
            }
            if(bg.time() >= 10 && bg.time() < 19){
                // console.log('中午')
                $('.sun1,.sun2,.moon').hide();
                $('.sun3').show();
            }
            if(bg.time() >= 19 && bg.time() < 30){
                // console.log('晚上')
                $('.sun1,.sun2,.sun3').hide();
                $('.moon').show();
            }
        },1000)
                
    }

    // 🐟
    var yu = new TimelineMax({});
    yu.from($(".yu"), 0.3, {right:'-40%',ease: Power0.easeNone,onStart:function(){yuUpDown();}});
    yu.pause();

    var yu2 = new TimelineMax({});
    yu2.from($(".yu2"), 0.3, {right:'-40%',ease: Power0.easeNone,onStart:function(){yuUpDown2()}});
    yu2.pause();

    var yu3 = new TimelineMax({});
    yu3.from($(".yu3"), 0.3, {right:'-40%',ease: Power0.easeNone,onStart:function(){yuUpDown3()}});
    yu3.pause();

    function yuUpDown(){
        var yuUp = new TimelineMax({repeat:-1});
        yuUp.to($('.yu'), 1, {top:'95.4%',ease: Power0.easeNone});
        yuUp.to($('.yu'), 1, {top:'95%',ease: Power0.easeNone});
    }
    function yuUpDown2(){
        var yuUp2 = new TimelineMax({repeat:-1});
        yuUp2.to($('.yu2'), 1, {top:'82.4%',ease: Power0.easeNone});
        yuUp2.to($('.yu2'), 1, {top:'82%',ease: Power0.easeNone});
    }
    function yuUpDown3(){
        var yuUp3 = new TimelineMax({repeat:-1});
        yuUp3.to($('.yu3'), 1, {top:'77.4%',ease: Power0.easeNone});
        yuUp3.to($('.yu3'), 1, {top:'77%',ease: Power0.easeNone});
    }
    // 🐟网
    var yuwang = new TimelineMax({repeat:-1});
    yuwang.from($(".yuwang"), 1, {   rotation: "-30deg",transformOrigin: "0% 100%",ease: Power0.easeNone});
    yuwang.to($(".yuwang"), 1, {   rotation: "-30deg",transformOrigin: "0% 100%",ease: Power0.easeNone});
    yuwang.pause();

    var yuwang2 = new TimelineMax({repeat:-1});
    yuwang2.from($(".yuwang2"), 1, {rotation: "40deg",transformOrigin: "100% 100%",ease: Power0.easeNone},0);
    yuwang2.to($(".yuwang2"), 1, {rotation: "40deg",transformOrigin: "100% 100%",ease: Power0.easeNone});
    yuwang2.pause();

    var yuwang3 = new TimelineMax({repeat:-1});
    yuwang3.from($(".yuwang3"), 1, {rotation: "-30deg",transformOrigin: "0% 100%",ease: Power0.easeNone});
    yuwang3.to($(".yuwang3"), 1, {rotation: "-30deg",transformOrigin: "0% 100%",ease: Power0.easeNone});
    yuwang3.pause();

    var yuwang4 = new TimelineMax({repeat:-1});
    yuwang4.from($(".yuwang4"), 1, {rotation: "-30deg",transformOrigin: "0% 100%",ease: Power0.easeNone});
    yuwang4.to($(".yuwang4"), 1, {rotation: "-30deg",transformOrigin: "0% 100%",ease: Power0.easeNone});
    yuwang4.pause();

    // 🐸
    // var qingwa = new TimelineMax({repeat:-1});
    // qingwa.to($(".qingwa"), 1, { left: '5%',ease: Power0.easeNone});
    // qingwa.to($(".qingwa"), 1, { left: '0%',ease: Power0.easeNone});
    // qingwa.pause();
    
    // var qingwa2 = new TimelineMax({repeat:-1});
    // qingwa2.to($(".qingwa2"), 1, { right: '5%',ease: Power0.easeNone},0);
    // qingwa2.to($(".qingwa2"), 1, { right: '0%',ease: Power0.easeNone});
    // qingwa2.pause();


    // 🐦
    var niao = new TimelineMax({});
    niao.from($(".niao"), 2, { left: '-30%',ease: Power0.easeNone});
    niao.pause();

    var niao2 = new TimelineMax({});
    niao2.from($(".niao2"), 2, { left: '-30%',ease: Power0.easeNone});
    niao2.pause();

    // 🐒


    var houzi = new TimelineMax({});
    houzi.from($('.houzi'), 2, { right: '-30%',ease: Power0.easeNone,onStart:function(){houziUpDown1()}});
    houzi.pause();

    var houzi2 = new TimelineMax({});
    houzi2.from($('.houzi2'), 2, { left: '-30%',ease: Power0.easeNone,onStart:function(){houziUpDown2()}});
    houzi2.pause();

    var houzi3 = new TimelineMax({});
    houzi3.from($('.houzi3'), 2, { right: '-30%',ease: Power0.easeNone,onStart:function(){houziUpDown3()}});
    houzi3.pause();


    function houziUpDown1 (){
        var houziUp = new TimelineMax({repeat:-1});
        houziUp.to($('.houzi'), 1, {top:'56.3%',ease: Power0.easeNone});
        houziUp.to($('.houzi'), 1, {top:'56%',ease: Power0.easeNone});
    }
    function houziUpDown2 (){
        var houziUp2 = new TimelineMax({repeat:-1});
        houziUp2.to($('.houzi2'), 1, {top:'50.3%',ease: Power0.easeNone});
        houziUp2.to($('.houzi2'), 1, {top:'50%',ease: Power0.easeNone});
    }
    
    function houziUpDown3 (){
        var houziUp3 = new TimelineMax({repeat:-1});
        houziUp3.to($('.houzi3'), 1, {top:'40.8%',ease: Power0.easeNone});
        houziUp3.to($('.houzi3'), 1, {top:'40.5%',ease: Power0.easeNone});
    }
    // 车
    var p5che = new TimelineMax({repeat:-1});
    p5che.to($('.che'), 0.5, { autoAlpha: 0,ease: Power0.easeNone});
    p5che.to($('.che3'), 0.5, { autoAlpha: 1,ease: Power0.easeNone},'-=0.5');
    p5che.to($('.che'), 0.5, { autoAlpha: 1,ease: Power0.easeNone});
    p5che.pause();

    var p5che2 = new TimelineMax({repeat:-1});
    p5che2.to($('.che2'), 0.5, { autoAlpha: 0,ease: Power0.easeNone});
    p5che2.to($('.che4'), 0.5, { autoAlpha: 1,ease: Power0.easeNone},'-=0.5');
    p5che2.to($('.che2'), 0.5, { autoAlpha: 1,ease: Power0.easeNone});
    p5che2.pause();
    

    // 倒计时
    var Time = new TimelineMax({});
    Time.to($('.p5Three'), 0.5, { autoAlpha: 1,ease: Power0.easeNone});
    Time.to($('.p5Three'), 0.5, { autoAlpha: 0,ease: Power0.easeNone});
    Time.to($('.p5Two'), 0.5, { autoAlpha: 1,ease: Power0.easeNone});
    Time.to($('.p5Two'), 0.5, { autoAlpha: 0,ease: Power0.easeNone});
    Time.to($('.p5One'), 0.5, { autoAlpha: 1,ease: Power0.easeNone});
    Time.to($('.p5One'), 0.5, { autoAlpha: 0,ease: Power0.easeNone});
    Time.to($('.timeDown'), 0.5, { autoAlpha: 0,ease: Power0.easeNone,onStart:function(){bg.seek(0).play();changePang();}},'-=0.5');
    Time.pause();

    // 倒计时结束 执行 替换螃蟹图片
    function changePang (){
        $('.pangxie').attr('src',viwer+'images/game/pangxie.gif')
    };


    // 成功
    var p6 = new TimelineMax({repeat:-1});
    p6.from($('.p6guang'), 5, { rotation: "360deg", transformOrigin: "50% 50%",ease: Power0.easeNone,onStart:function(){p6Alpha();}});

    function p6Alpha (){
        var p6Alpha = new TimelineMax({repeat:-1});
        p6Alpha.to($('.p6guang'), 1.5, { autoAlpha: 0,ease: Power0.easeNone});
        p6Alpha.to($('.p6guang'), 1.5, { autoAlpha: 1,ease: Power0.easeNone});
    }

    p6.pause();
    var p6btn =new TimelineMax({repeat:-1});
    p6btn.to($('.p6hui'), 1, { rotation: "5deg", transformOrigin: "50% 50%",ease: Power0.easeNone});
    p6btn.to($('.p6hui'), 1, { rotation: "0deg", transformOrigin: "50% 50%",ease: Power0.easeNone});
    p6btn.pause();


    //loading
    function step1() {
        $('.allPage1').hide();
        $('.allPage2').show();  
        step2();
    }

    function step2() {
        $('.p2btn').off('click');
        $('.p2btn').click(function(){
            $('.allPage2').hide();
            $('.allPage3').show();
            step3();
        });
    }
    var p3time;
    function step3() {
        p3Manhua.seek(0).play();
        p3title.seek(0).play();
        p3xing.seek(0).play();
        p3time = setTimeout(function(){
            $('.allPage3').hide();
            $('.allPage4').show();  
            step4();
        },8000); 

        $('.allPage3').off('click');
        $('.allPage3').click(function(){
            $('.allPage3').hide();
            $('.allPage4').show();  
            step4();
        })
    }

    function step4() {
        p3Manhua.pause();
        p3title.pause();
        p3xing.pause();

        clearTimeout(p3time);
        p4Btn.seek(0).play();
        $('.p4btn').off('click');
        $('.p4btn').click(function(){
            $('.allPage4').hide();
            $('.allPage5').show();  
            p4Btn.pause();
            step5();
        });
    }
    var setTimePlau ;
    var setTimeCouter;

    function step5() {


        bg.seek(0).pause();
        yu.seek(0).pause();
        yuwang.seek(0).pause();
        yuwang2.seek(0).pause();
        yuwang3.seek(0).pause();
        yu2.seek(0).pause();
        yu3.seek(0).pause();
        yuwang4.seek(0).pause();
        // qingwa2.seek(0).pause();
        niao.seek(0).pause();
        houzi.seek(0).pause();
        houzi2.seek(0).pause();
        niao2.seek(0).pause();
        houzi3.seek(0).pause();

        var obj = [

        ];

        var objLeft = [

        ];
        var bgjzd = [];
        //倒计时3秒
        Time.seek(0).play();
        // p4动画开始
        setTimePlau = setInterval(function(){
            // console.log(bg.time());
            if(bg.time() >= 0.5){
                yu.play();
                // bg.pause();
            }
            if(bg.time() >= 0.8){
                yuwang.play();
            }
            if(bg.time() >=1.4){
                yuwang2.play();
            }
            // if(bg.time() >=2.1){
            //     qingwa.play();
            // }
            if(bg.time() >=5){
                yuwang3.play();
                yu2.play();
            }
            if(bg.time() >=6){
                yu3.play();
                yuwang4.play();
            }
            // if(bg.time() >=6){
            //     qingwa2.play();
            // }
            if( bg.time()>= 10){
                niao.play();
            }
            if(bg.time()>=12){
                houzi.play();
            }
            if(bg.time()>=14){
                houzi2.play();
            }
            if(bg.time()>=16){
                niao2.play();
            }
            if(bg.time()>=17){
                houzi3.play();
            }
            
            if(bg.time()>=23){
                p5che2.play();

            }
            if(bg.time()>=25){
                p5che.play();
            }

           
        },100)

        //碰撞
        setTimeCouter = setInterval(function(){

            var px = document.getElementById("pangxie");
            var pxLeft = px.offsetLeft+5;
            var pxTop = px.offsetTop;
            var pxRight = pxLeft + $('.pangxie').width()-5;
            var pxBottom = pxTop + $('.pangxie').height();

        var boxBottom = parseInt($('.box').css('bottom').split('px')[0]);   
        var obj =[
                    // 上     下     左     右
            ['yu','-300','-234','225','340','.p7yu'],
            ['yu','-313','-204','350','375','.p7yu'],
            ['yuwang2','-910','-765','249','375','.p7wang'],
            ['yu2','-1370','-1300','225','340','.p7yu'],  
            ['yu2','-1380','-1290','350','375','.p7yu'],  
            ['yu3','-1785','-1705','225','340','.p7yu'],
            ['yu3','-1775','-1685','350','375','.p7yu'],
            ['xiezi2','-2980','-2920','340','375','.p7xie'],//2890
            ['houzi','-3460','-3385','270','375','.p7hou'],//3385
            ['xiezi4','-4220','-4100','340','375','.p7xie'],//4100
            ['houzi3','-4750','-4650','270','375','.p7hou'],//4650
            ['shitou3','-5090','-5050','300','375','.p7shi'],//5050
            ['che','-6180','-6080','255','375','.p7che'],//6070
            ['che3','-6180','-6080','255','375','.p7che'],//6070
            ['shu','-6980','-6825','300','375','.p7shu'],//6820

            ['yuwang','-620','-510','0','126','.p7wang'],//510
            ['yuwang3','-1590','-1500','0','126','.p7wang'],//1500
            ['yuwang4','-1990','-1900','0','126','.p7wang'],//1900
            ['xiezi','-2780','-2670','0','150','.p7xie'],//2620
            ['niao','-3150','-3090','0','140','.p7niao'],//3090
            ['niao2','-4550','-4400','0','140','.p7niao'],//3090
            ['xiezi3','-3640','-3560','0','140','.p7xie'],//3530
            ['houzi2','-3960','-3880','0','120','.p7hou'],//3880
            ['shitou2','-5090','-5055','0','95','.p7shi'],//5050
            ['che2','-5660','-5560','0','120','.p7che'],//5560
            ['che4','-5660','-5560','0','120','.p7che'],//5560
            ['shitou','-6600','-6525','0','140','.p7shi'],//6530
        ];
        

        for(var i = 0; i<obj.length;i++ ){

            if( boxBottom >=  obj[i][1] * ww/414  &&  boxBottom <=  obj[i][2] * ww/414){
                if(pxRight <  obj[i][3] || pxLeft> obj[i][4]){
               
                }else{
                    bg.pause();
                    $('.allPage7').show();
                    $(obj[i][5]).show();
                    step7();
                }
            }
        }


        var bgjzd = ['zhongdian','-7600','-7136',''];
        
        if( boxBottom <=  bgjzd[2]* ww/414+2 ){
            bg.pause();
            $('.allPage6').show();
            $('.allPage5').hide();
            step6();
           
            clearInterval(setTimeCouter);
           
        }   


        },50);


        // 重力感应
        var i = 0;
        var o = new Orienter();
        var opj;
        // var tip = document.getElementById('tip');
        o.onOrient = function (obj) {
            // tip.innerHTML =
            //     'alpha-Z:' + obj.a +
            //     '<br>' + 'beta-Y:' + obj.b +
            //     '<br>' + 'gamma-X:' + obj.g +
            //     '<br>' + 'longitude:' + obj.lon +
            //     '<br>' + 'latitude:' + obj.lat +
            //     '<br>' + 'direction:' + obj.dir;
            // alert(obj.a)
            if (obj.a == 0) {
                console.log('初始')
            }

            // 向左转动
            if (obj.g < 0 && obj.g >= -90) {
                console.log('向左 10度');
                pxAnmX();
            }

            // 向右转动
            if (obj.g > 0 && obj.g <= 90) {
                console.log('向右10度')
                pxAnmX();
            }
            
            if(obj.g >40){
                opj = 40;
            }else  if(obj.g <-40){
                opj = -40;
            }else{
                opj = obj.g;
            }

            // 控制螃蟹左右
            function pxAnmX() {
                var t1 = new TimelineMax({});
                t1.to($(".pangxie"), 0.3, { left: (opj + 36) + "%", ease: Power0.easeNone });
            }
            // 控制螃蟹上下
            function pxAnmY() {
                var t3 = new TimelineMax({});
                t3.to($(".pangxie"), 0.3, { top: (obj.b + 35) + "%", ease: Power0.easeNone });
            }
        };
        o.init();
    }
    function step6() {

        clearInterval(setTimePlau);
        clearInterval(setTimeCouter);

        $('.allPage6').show();
        $('.allPage5').hide();

        yu.pause();
        yu2.pause();
        yu3.pause();
        yuwang.pause();
        yuwang2.pause();
        yuwang3.pause();
        yuwang4.pause();
        // qingwa.pause();
        // qingwa2.pause();
        p5che.pause();
        p5che2.pause();
        niao.pause();
        niao2.pause();
        houzi.pause();
        houzi2.pause();
        houzi3.pause();
        Time.pause();


        $('.allPage6').show();
        p6.seek(0).play();
        p6btn.seek(0).play();

        $('.p6btn').off('click');
        $('.p6btn').click(function(){
            $('.allPage6').hide();
            $('.allPage5').show();
            $('.p7fail').hide();
            step5();
        })
    }

    function step7() {
        
        clearInterval(setTimePlau);
        clearInterval(setTimeCouter);

        yu.pause();
        yu2.pause();
        yu3.pause();
        yuwang.pause();
        yuwang2.pause();
        yuwang3.pause();
        yuwang4.pause();
        // qingwa.pause();
        // qingwa2.pause();
        p5che.pause();
        p5che2.pause();
        niao.pause();
        niao2.pause();
        houzi.pause();
        houzi2.pause();
        houzi3.pause();
        Time.pause();
        


        $('.allPage7').show();

        $('.agent').off('click');
        $('.agent').click(function(){
            $('.allPage7').hide();
            $('.allPage5').show();
            $('.p7fail').hide();
            step5();
        })
    }




    function resize() {
        var ww = $(window).width();
        var wh = $(window).height();

        var s = $('.p3bg1').height();
        $('.p3bg2').css('top',s*0.68);
        $('.p3bg3').css('top',s*1.53);
        $('.p3xing').css('top',s*1.6);
        $('.p3title').css({'top':s*0.33,'right':s*0.2});

        var l = $('.p7fail').height();
        $('.p7fail').css('top',l*0.25);
        $('.agent,.go img').css('top',l*1.25);
        // alert(wh +','+ww);
        if (wh / ww < 1.48) {}
        if (wh / ww > 1.48 && wh / ww < 1.53) {}
        if (wh / ww > 1.6 && wh / ww < 1.61) {}
        if (wh / ww > 1.61 && wh / ww < 1.7) {}
        if (wh / ww > 1.7) {}
        if (wh / ww > 1.55 && wh / ww < 1.6) {}
    }

    setInterval(function () {
        resize();

    }, 500);

});